/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.agi.util.sound;

import br.com.agi.util.geradordados.ManipuladorByte;

/**
 *
 * @author Renato
 */
public class ManipuladorMultiplicador implements ManipuladorByte {
    private byte[] buf;
    private ManipuladorByte manipulador;
    private double fator;
    public ManipuladorMultiplicador(ManipuladorByte manipulador){
        this.manipulador=manipulador;
        this.fator=1;
        this.buf=manipulador.getBuf();
    }
    
    @Override
    public void setBuf(byte[] buf) {
        this.buf=buf;        
    }

    @Override
    public void manipula(int off, int len) {
        manipulador.manipula(off, len);
        int end;
        end=off+len;
        for(int i=off;i<end;i++){
            buf[i]=(byte)(buf[i] * fator);
        }        
    }    
    @Override
    public byte[] getBuf(){
        return buf;
    }
    
    public void setFator(double fator){
        this.fator=fator;
    }

    @Override
    public void open() throws Exception {
        this.manipulador.open();
    }

    @Override
    public void close() {
        this.manipulador.close();
    }
}
